<div class="jumbotron simple">
    <div class="container">
        <h1><?php echo $catParent['name']?> <small id="cat_child_name"><?php if($catChild):?><?php echo $catChild['name']?><?php endif?></small></h1>
        <?php if($catDesc):?>
        <p class="hidden-xs"><?php echo $catDesc?></p>
        <?php endif?>
    </div>
</div>


<div id="container-main" class="container">
    <div class="row">
        <div class="col-md-18">

            <div id="panel-cats" <?php if($catChild):?>style="display: none;"<?php endif?>>
                <?php $this->renderPartial('//hangve/page/_panel_forum', array('catParent' => $catParent))?>
            </div>
            
            <div class="row">
                <div class="col-lg-24">
                    <ul id="nav-sort" class="nav nav-pills nav-stacked nav-justified nav-success text-bold">
                        <?php foreach($model->sortData as $k => $v):?>
                            <li <?php if($model->sort == $k):?>class="active"<?php endif?>>
                                <a data-toggle="tab" rel="<?php echo $k?>" class="pointer"><?php echo $v?></a>
                            </li>
                        <?php endforeach?>
                    </ul>
                </div> 
                <div class="col-lg-24 text-right margintop5 marginbottom5">
                    <a id="toogle-filter" class="btn btn-xs btn-default">
                        <i class="fa fa-search-<?php echo $toogleFilterOpen ? 'minus' : 'plus';?>"></i> Lọc bài
                    </a>
                </div> 
            </div>
            
            <?php /*
                Lọc: Thành phố, quận huyện

                SALE: 
                - Loại tin: mua , bán
                - Tình trạng: cũ, mới, gần như mới
                - Giá:

                IMMOVABLE: 
                - Loại tin: mua , bán, thuê, cho thuê
                - Diện tích sử dụng:
                - Diện tích mặt bằng:
                - Giá: 
                SERVICE:
                - Giá: 

                ARTICLE:

                Sắp xếp:
                - Cập nhật mới
                - Chủ đề mới
            */?>
            
            <div id="search-form" style="display: <?php echo $toogleFilterOpen ? 'block' : 'none';?>">
            <?php /*
                <div class="row margintop10">
                    <?php $form=$this->beginWidget('CActiveForm', array(
                            'id'=>'filter_form',
                            'action'=>$catParent['url'],
                            'method'=>'get',
                        )); ?>
                    <?php echo $form->hiddenField($model,'sort',array('name'=>'sap-xep')); ?>

                    <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                        <?php echo $form->label($model,'keyword', array('for' => 'tim-kiem', 'class' => 'text-bold marginbottom0')); ?>
                        <?php echo $form->textField($model, 'keyword', array('name' => 'tim-kiem', 'class'=>'form-control input-sm', 'placeholder' => 'Nhập từ khóa')); ?>
                    </div>
                    <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                        <?php echo $form->label($model,'cat_alias', array('for' => 'child_alias', 'class' => 'text-bold marginbottom0')); ?>
                        <?php echo $form->dropDownList($model, 'cat_alias', CHtml::listData($catParent['cats'], 'alias', 'name'), array('name' => 'child_alias', 'class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                    </div>
                    <?php if(in_array($catParent['type'], array('SALE', 'IMMOVABLE', 'SERVICE'))):?>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->label($model,'city_alias', array('for' => 'thanh-pho', 'class' => 'text-bold marginbottom0')); ?>
                            <?php echo $form->dropDownList($model, 'city_alias', City::model()->getData('alias'), array('name' => 'thanh-pho', 'class'=>'form-control input-sm', 'empty' => 'Toàn quốc')); ?>
                        </div>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->label($model,'district_alias', array('for' => 'quan', 'class' => 'text-bold marginbottom0')); ?>
                            <?php echo $form->dropDownList($model, 'district_alias', $districtData, array('name' => 'quan', 'class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                        </div>
                        <?php endif?>

                    <?php if(in_array($catParent['type'], array('SALE', 'IMMOVABLE'))):?>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->label($model,'type', array('for' => 'loai-tin', 'class' => 'text-bold marginbottom0')); ?>
                            <?php echo $form->dropDownList($model, 'type', $typeData, array('name' => 'loai-tin', 'class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                        </div>
                        <?php endif?>

                    <?php if($catParent['type'] == 'SALE'):?>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->label($model,'state', array('for' => 'tinh-trang', 'class' => 'text-bold marginbottom0')); ?>
                            <?php echo $form->dropDownList($model, 'state', $model->stateData, array('name' => 'tinh-trang', 'class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                        </div>
                        <?php endif?>

                    <?php if($catParent['type'] == 'IMMOVABLE'):?>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->label($model,'area_use_about', array('for' => 'dien-tich-su-dung', 'class' => 'text-bold marginbottom0')); ?>
                            <?php echo $form->dropDownList($model, 'area_use_about', $model->areaAboutData, array('name' => 'dien-tich-su-dung', 'class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                        </div>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->label($model,'area_floor_about', array('for' => 'dien-tich-mat-bang', 'class' => 'text-bold marginbottom0')); ?>
                            <?php echo $form->dropDownList($model, 'area_floor_about', $model->areaAboutData, array('name' => 'dien-tich-mat-bang', 'class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                        </div>

                        <?php endif?>

                    <?php if(in_array($catParent['type'], array('SALE', 'IMMOVABLE', 'SERVICE'))):?>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->label($model,'price_from', array('for' => 'gia-tu', 'class' => 'text-bold marginbottom0')); ?>
                            <?php echo $form->dropDownList($model, 'price_from', $model->priceData, array('name' => 'gia-tu', 'class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                        </div>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->label($model,'price_to', array('for' => 'gia-den', 'class' => 'text-bold marginbottom0')); ?>
                            <?php echo $form->dropDownList($model, 'price_to', $model->priceData, array('name' => 'gia-den', 'class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                        </div>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->label($model,'status', array('for' => 'trang-thai', 'class' => 'text-bold marginbottom0')); ?>
                            <?php echo $form->dropDownList($model, 'status', $model->getStatusData(false), array('name' => 'trang-thai', 'class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                        </div>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <label></label>
                            <div style="padding: 3px 0">
                                <abbr rel="tooltip" title="Chỉ hiển thị những bài có ảnh">
                                <?php echo $form->checkBox($model,'has_image', array('name' => 'co-anh')); ?>
                                <?php echo $form->label($model,'has_image', array(
                                        'for' => 'co-anh',
                                        'style' => 'display: inline', 
                                        'class' => 'text-bold', 
                                        'label' => $model->getAttributeLabel('has_image')
                                    )); ?>
                                </abbr>
                            </div>
                        </div>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10" id="is_all_city_block" <?php if(!$model->city_alias):?> style="display: none;"<?php endif?>>
                            <label></label>
                            <div style="padding: 3px 0">
                                <abbr rel="tooltip" title="Hiển thị cả những bài được chọn rao toàn quốc">
                                <?php echo $form->checkBox($model,'is_all_city', array('name' => 'toan-quoc')); ?>
                                <?php echo $form->label($model,'is_all_city', array(
                                        'for' => 'toan-quoc',
                                        'style' => 'display: inline', 
                                        'class' => 'text-bold', 
                                        'label' => $model->getAttributeLabel('is_all_city')
                                    )); ?>
                                </abbr>
                            </div>
                        </div>
                        <?php endif?>

                    <?php $this->endWidget(); ?>

                </div>
            */?>
                <div class="row">
                    <?php $form=$this->beginWidget('CActiveForm', array(
                            'id'=>'filter_form',
                            'action'=>$catParent['url'],
                            'method'=>'get',
                            'htmlOptions' => array('cat_parent_alias' => $catParent['alias'])
                        )); ?>
                    <?php echo $form->hiddenField($model,'sort',array('name'=>'sap-xep')); ?>

                    <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                        <?php echo $form->textField($model, 'keyword', array('name' => 'tim-kiem', 'class'=>'form-control input-xs', 'placeholder' => 'Nhập từ khóa')); ?>
                    </div>
                    <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                        <?php echo $form->dropDownList($model, 'cat_alias', CHtml::listData($catParent['cats'], 'alias', 'name'), array('name' => 'child_alias', 'class'=>'form-control input-xs', 'empty' => $model->getAttributeLabel('cat_alias'))); ?>
                    </div>
                    <?php if(in_array($catParent['type'], array('SALE', 'IMMOVABLE', 'SERVICE'))):?>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->dropDownList($model, 'city_alias', City::model()->getData('alias'), array('name' => 'thanh-pho', 'class'=>'form-control input-xs', 'empty' => $model->getAttributeLabel('city_alias'))); ?>
                        </div>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->dropDownList($model, 'district_alias', $districtData, array('name' => 'quan', 'class'=>'form-control input-xs', 'empty' => $model->getAttributeLabel('district_alias'))); ?>
                        </div>
                        <?php endif?>

                    <?php if(in_array($catParent['type'], array('SALE', 'IMMOVABLE'))):?>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->dropDownList($model, 'type', $typeData, array('name' => 'loai-tin', 'class'=>'form-control input-xs', 'empty' => $model->getAttributeLabel('type'))); ?>
                        </div>
                        <?php endif?>

                    <?php if($catParent['type'] == 'SALE'):?>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->dropDownList($model, 'state', $model->stateData, array('name' => 'tinh-trang', 'class'=>'form-control input-xs', 'empty' => $model->getAttributeLabel('state'))); ?>
                        </div>
                        <?php endif?>

                    <?php if($catParent['type'] == 'IMMOVABLE'):?>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->dropDownList($model, 'area_use_about', $model->areaAboutData, array('name' => 'dien-tich-su-dung', 'class'=>'form-control input-xs', 'empty' => $model->getAttributeLabel('area_use_about'))); ?>
                        </div>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->dropDownList($model, 'area_floor_about', $model->areaAboutData, array('name' => 'dien-tich-mat-bang', 'class'=>'form-control input-xs', 'empty' => $model->getAttributeLabel('area_floor_about'))); ?>
                        </div>

                        <?php endif?>

                    <?php if(in_array($catParent['type'], array('SALE', 'IMMOVABLE', 'SERVICE'))):?>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->dropDownList($model, 'price_from', $model->priceData, array('name' => 'gia-tu', 'class'=>'form-control input-xs', 'empty' => $model->getAttributeLabel('price_from'))); ?>
                        </div>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->dropDownList($model, 'price_to', $model->priceData, array('name' => 'gia-den', 'class'=>'form-control input-xs', 'empty' => $model->getAttributeLabel('price_to'))); ?>
                        </div>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10">
                            <?php echo $form->dropDownList($model, 'status', $model->getStatusData(false), array('name' => 'trang-thai', 'class'=>'form-control input-xs', 'empty' => $model->getAttributeLabel('status'))); ?>
                        </div>  
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10 <?php if($catParent['type'] == 'SERVICE'):?>service-clear<?php endif?>" id="filter-has-image">
                            <?php echo $form->checkBox($model,'has_image', array('name' => 'co-anh')); ?>
                            <?php echo $form->label($model,'has_image', array(
                                    'for' => 'co-anh',
                                    'style' => 'display: inline', 
                                    'class' => 'text-normal text-mini', 
                                    'title' => $model->getAttributeLabel('has_image')
                                )); ?>
                            <abbr class="text-muted text-mini" rel="tooltip" title="Chỉ hiển thị những bài có ảnh"><i class="fa fa-question-circle"></i></abbr>
                        </div>
                        <div class="col-lg-4 col-md-6 col-sm-8 col-xs-12 marginbottom10" id="is_all_city_block" <?php if(!$model->city_alias):?> style="display: none;"<?php endif?>>
                            
                            <?php echo $form->checkBox($model,'is_all_city', array('name' => 'toan-quoc')); ?>
                            <?php echo $form->label($model,'is_all_city', array(
                                    'for' => 'toan-quoc',
                                    'style' => 'display: inline', 
                                    'class' => 'text-normal text-mini', 
                                    'title' => $model->getAttributeLabel('is_all_city')
                                )); ?>
                            <abbr class="text-muted text-mini" rel="tooltip" title="Hiển thị cả những bài được chọn rao toàn quốc"><i class="fa fa-question-circle"></i></abbr>
                        </div>
                        <?php endif?>

                    <?php $this->endWidget(); ?>

                </div>

            </div>




            <?php $this->widget('zii.widgets.CListView', array(
                    'id'=>'post-list',
                    'ajaxVar'=> '',
                    'dataProvider'=>$dataProvider,
                    'itemView'=>'_view',
                    'ajaxUpdate'=> true,
                    'beforeAjaxUpdate'=>'function(id,options){
                        $("#ajax-loading").fadeIn();
                    }',
                    'afterAjaxUpdate'=>'function(id,options){
                        $("#ajax-loading").fadeOut();
                    }',
                    'itemsCssClass' => 'items',
                    'loadingCssClass' => '',
                    'template' => "{items} {pager}",
                    'emptyTagName' => 'div class="jumbotron small"',
                    'emptyText' => "Không có bài viết nào.",
                    'enablePagination'=>true,
                    'pagerCssClass' => 'text-right',
                    'pager'=>array(
                        'class'=>'CLinkPager',
                        'itemCount'=>$dataProvider->pagination->itemCount,
                        'pageSize'=>$dataProvider->pagination->pageSize,
                        'maxButtonCount'    =>  10,
                        'header'            => FALSE,
                        'htmlOptions' => array(
                            'id' => 'pagination-post',
                            'class' => 'pagination  pagination-sm',
                        ),
                        'hiddenPageCssClass' => 'disabled',
                        'selectedPageCssClass' => 'active',
                        'lastPageLabel' => '&raquo;',
                        'firstPageLabel' => '&laquo;',
                        'nextPageLabel' => '<small>Sau</small> &rsaquo;',
                        'prevPageLabel' => '&lsaquo; <small>Trước</small>',
                    ),
                ));?>
            <?php //$this->widget('CLinkPager', array(
                //                    'itemCount'=>$total,
                //                    'pageSize'=>$pageSize,
                //                    'maxButtonCount'    =>  10,
                //                    'header'            => FALSE,
                //                    'htmlOptions' => array(
                //                        'class' => 'pagination',
                //                    ),
                //                    'hiddenPageCssClass' => 'disabled',
                //                    'selectedPageCssClass' => 'active',
                //                ));?>
        </div>
        <div class="col-md-6">
            <?php $this->renderPartial('//common/sidebar')?>
        </div>
    </div>
</div>
<script>
    var $cityData = <?php echo json_encode($this->cities)?>;
    var $catData = <?php echo json_encode($cats)?>;
    var $sortData = <?php echo json_encode($model->sortData)?>;
    var $typeData = <?php echo json_encode($model->typeData)?>;
    var $stateData = <?php echo json_encode($model->stateData)?>;
    var $statusData = <?php echo json_encode($model->statusData)?>;
    var $areaAboutData = <?php echo json_encode($model->areaAboutData)?>;
</script>
<script type="text/javascript" src="<?php echo $this->themeUrl?>/files/js/post_index.js"></script> 


